<%@ page language="java" import="java.util.*,java.sql.*"
	pageEncoding="UTF-8"%>
<html>
<head>
<title></title>
</head>

<body>
	<%
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url1 = "jdbc:mysql://localhost:3306/user";
			String url2 = "?user=root&password=123456";
			String url3 = "&useUnicode=true&characterEncoding=UTF-8";
			String url = url1 + url2 + url3;
			Connection con = DriverManager.getConnection(url);
			request.setCharacterEncoding("UTF-8");
			String password = request.getParameter("password");
			String pasw = request.getParameter("pasw");
			if (password.equals(pasw)) {
				String user = request.getParameter("user");
				String sql = "insert into register(user, password) values(?, ?)";
				PreparedStatement pstmt = con.prepareStatement(sql);
				pstmt.setString(1, user);
				pstmt.setString(2, password);
				int n = pstmt.executeUpdate();
				if (n == 1)
					out.print("注册成功"+"<br>");
				if (pstmt != null) {
					pstmt.close();
				}
				if (con != null) {
					con.close();
				}
			} else {
				out.print("密码格式错误"+"<br>");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	%>
	<a href="register.jsp">注册</a>&nbsp;&nbsp;<a href="login.jsp">登录</a>
</body>
</html>
